#ifndef DB_INFO_H
#define DB_INFO_H

#include <pthread.h>

#define DB_TYPE_NAME_MAX_LEN 64
#define DB_NAME_MAX_LEN 64
#define DB_USER_NAME_MAX_LEN 64
#define DB_PASSWD_MAX_LEN 64
#define DB_ADDRESS_MAX_LEN 16

struct db_data {
	struct db_data *next;

	char db_type_name[DB_TYPE_NAME_MAX_LEN + 1];
	char db_name[DB_NAME_MAX_LEN + 1];
	char db_user_name[DB_USER_NAME_MAX_LEN + 1];
	char db_passwd[DB_PASSWD_MAX_LEN + 1];
	char db_address[DB_ADDRESS_MAX_LEN + 1];

	pthread_mutex_t lock;
	unsigned short count;

	unsigned int alive;
};

struct db_info {
	pthread_mutex_t lock;
	unsigned short count;

	struct db_data *db_list_head;
};

extern struct db_info *db_info_create(void);
void add_db_data(struct db_info *db_info, char *db_type_name, char *db_name, char *user_name, char *passwd, char *address);

#endif
